<template>
  <div class="container" style="text-align: left;">
    <h4>请添加患者信息</h4>
    <h5><small>以便医生给出更准确的治疗，信息仅医生可见</small></h5>
    <h6>&nbsp;</h6>
    <form class="form-horizontal" >
      <div class="form-group">
        <label for="name" class="col-sm-2 control-label text-left">姓名</label>
        <div class="col-sm-4">
          <el-input v-model="name" placeholder="请输入姓名"
                    onkeyup="value=value.replace(/[\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))"
          ></el-input>
        </div>
      </div>
      <div class="form-group">
        <label for="xb" class="col-sm-2 control-label text-left">性别</label>
        <div class="col-sm-4">
          <div class="radio-inline">
            <el-radio v-model="radio" label="1">男</el-radio>
            <el-radio v-model="radio" label="0">女</el-radio>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label for="age" class="col-sm-2 control-label text-left">年龄</label>
        <div class="col-sm-4">
          <el-input v-model="birthday" placeholder="请输入年龄"></el-input>
        </div>
      </div>
      <div class="form-group">
        <label for="wei" class="col-sm-2 control-label text-left">体重</label>
        <div class="col-sm-4">
          <el-input v-model="wei" placeholder="0"></el-input>
        </div>
      </div>
      <div class="form-group">
        <label for="gms" class="col-sm-2 control-label text-left">过敏史</label>
        <div class="col-sm-4">
          <el-input
            type="textarea"
            :rows="4"
            placeholder="请填写过敏药物（非常重要）"
            v-model="textarea1">
          </el-input>
        </div>
      </div>
      <div class="form-group">
        <label for="gwbs" class="col-sm-2 control-label text-left">过往病史</label>
        <div class="col-sm-4">
          <el-input
            type="textarea"
            :rows="4"
            placeholder="请填写肝肾功能状况及过往病史（选填）"
            v-model="textarea2">
          </el-input>
        </div>
      </div>
      <a :href=this.url type="submit"  class="btn btn-success btn-lg btn-block btn-check" @click="onSubmit">支付{{price}}元</a>
    </form>
  </div>
</template>

<script>
  export default {
    name: 'Third',
    data() {
      return {
        name:'',
        birthday:'',
        wei:'',
        radio:'',
        textarea1: '',
        textarea2: '',
        url: '',
        price:'',
        priceList: [],
      }
    },
    methods:{
      onSubmit() {
        localStorage.setItem("vipName", this.name);
        localStorage.setItem("vipBirthday", this.birthday);
        localStorage.setItem("vipWei", this.wei);
        localStorage.setItem("vipSex", this.radio);
        localStorage.setItem("vipG", this.textarea1);
        localStorage.setItem("vipP", this.textarea2);
        var opid = localStorage.getItem("Opid");
        // var price = localStorage.getItem('vipPrice');
        // console.log(price)
        if (this.name === '' || this.radio === '' || this.birthday === '' || this.wei === ''  || this.wei<0||this.wei>600||this.birthday<0||this.birthday>150) {
          alert('您输入的信息不完整或者不准确');
        }else {
          console.log(this.url)
          this.url = "http://cy1996.natapp1.cc/pay?openid="+opid+"&price="+this.price;
        }
      },
      vipPrice() {
        this.$ajax.get('http://47.75.110.31:8080/adinfo/findByAccount?account=1')
          .then(response => {
            this.priceList = response.data;
            this.price =this.priceList[0].password;
            // localStorage.setItem('vipPrice', this.price);
          }).catch(function (err) {
          console.log(err)
        })
      }
    },
    mounted() {
      this.vipPrice();
    },
  }
</script>

<style scoped>
</style>
